import { validatePhone } from '@/utils/Validate'

import { useCommon } from '@/stores/Common'
import { useDevice } from '@/stores/Device'
import { reactive, toRefs } from 'vue'

const CommonStore = useCommon()
const DeviceStore = useDevice()
const { SecondLeafArr, FirstData, deviceOptions, deviceVersionOptions, versionOptions, deviceTypeOptions } = toRefs(CommonStore)

export const searchConfig = reactive({
    serial: {
        component: 'AInput',
        label: '序列号',
        attrs: {
            allowClear: true,
            placeholder: '序列号',
            style: {
                width: '100%'
            }
        },
    },
    deviceName: {
        component: 'AInput',
        label: '设备名称',
        attrs: {
            allowClear: true,
            placeholder: '设备名称',
            style: {
                width: '100%'
            }
        },
    },
    board: {
        component: 'AInput',
        label: 'SN',
        attrs: {
            allowClear: true,
            placeholder: 'SN',
            style: {
                width: '100%'
            }
        },
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            options: SecondLeafArr,
            changeOnSelect: true,
            style: {
                width: '100%'
            }
        },
    },
    state: {
        component: 'ASelect',
        label: '在线状态',
        attrs: {
            style: {
                width: '100%'
            },
            allowClear: true,
            placeholder: '在线状态',
            options: [
                { label: '在线', value: '在线' },
                { label: '离线', value: '离线' },
            ]
        },
    },
    versionId: {
        component: 'AInput',
        label: '版本号',
        attrs: {
            style: {
                width: '100%'
            },
            allowClear: true,
            placeholder: '版本号',

        },
    }
})
export const searchSelfConfig = {
    serial: {
        component: 'AInput',
        label: '序列号',
        attrs: {
            allowClear: true,
            placeholder: '序列号',
            style: {
                width: '100%'
            }
        },
    },
    deviceName: {
        component: 'AInput',
        label: '设备名称',
        attrs: {
            allowClear: true,
            placeholder: '设备名称',
            style: {
                width: '100%'
            }
        },
    },
    board: {
        component: 'AInput',
        label: 'SN',
        attrs: {
            allowClear: true,
            placeholder: 'SN',
            style: {
                width: '100%'
            }
        },
    },
    state: {
        component: 'ASelect',
        label: '在线状态',
        attrs: {
            style: {
                width: '100%'
            },
            allowClear: true,
            placeholder: '在线状态',
            options: [
                { label: '在线', value: '在线' },
                { label: '离线', value: '离线' },
            ]
        },
    },
    versionId: {
        component: 'AInput',
        label: '版本号',
        attrs: {
            style: {
                width: '100%'
            },
            allowClear: true,
        },
    }
}
export const addConfig = reactive({
    serial: {
        component: 'AInput',
        label: '序列号',
        attrs: {
            allowClear: true,
            placeholder: '序列号', style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入序列号', trigger: 'blur' },
        ]
    },
    deviceName: {
        component: 'AInput',
        label: '设备名称',
        attrs: {
            allowClear: true,
            placeholder: '设备名称',
            style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入设备名称', trigger: 'blur' },
        ]
    },
    deviceType: {
        component: 'ASelect',
        label: '设备类型',
        attrs: {
            allowClear: true,
            placeholder: '设备类型',
            options: deviceTypeOptions,
            style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请选择设备类型', trigger: 'change' },
        ]
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            options: SecondLeafArr,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入科室", trigger: 'blur' }]
    },
    area: {
        component: 'AInput',
        label: '所属区域',
        attrs: {
            allowClear: true,
            placeholder: '所属区域', style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入所属区域', trigger: 'blur' },
        ]
    },
    principal: {
        component: 'AInput',
        label: '维护人',
        attrs: {
            allowClear: true,
            placeholder: '维护人', style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入维护人', trigger: 'blur' },
        ]
    },
    tell: {
        component: 'AInput',
        label: '联系方式',
        attrs: {
            allowClear: true,
            placeholder: '联系方式', style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, validator: validatePhone, trigger: 'blur' },
        ]
    }
})
export const editConfig = reactive({
    serial: {
        component: 'AInput',
        label: '序列号',
        attrs: {
            allowClear: true,
            placeholder: '序列号',
            disabled: true, style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入序列号', trigger: 'blur' },
        ]
    },
    board: {
        component: 'AInput',
        label: 'SN',
        attrs: {
            allowClear: true,
            placeholder: 'SN',
            disabled: true, style: {
                width: '100%'
            }
        },
        rules: [
            { required: true, message: '请输入SN', trigger: 'blur' },
        ]
    },
    deviceName: {
        component: 'AInput',
        label: '设备名称',
        attrs: {
            allowClear: true,
            placeholder: '设备名称',
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '请输入设备名称', trigger: 'blur' }]
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            options: SecondLeafArr,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入科室", trigger: 'blur' }]
    },
    area: {
        component: 'AInput',
        label: '安装位置',
        attrs: {
            allowClear: true,
            placeholder: '安装位置', style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '请输入安装位置', trigger: 'blur' }]
    },
    principal: {
        component: 'AInput',
        label: '维护人',
        attrs: {
            allowClear: true,
            placeholder: '维护人', style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '请输入维护人', trigger: 'blur' }]
    },
    tell: {
        component: 'AInput',
        label: '联系方式',
        attrs: {
            allowClear: true,
            placeholder: '联系方式', style: {
                width: '100%'
            }
        },
        rules: [{ required: true, validator: validatePhone, trigger: 'blur' }]
    }
})

export const infoConfig = {
    disinfectData: {
        component: 'AInputNumber',
        label: '消毒时长设定(分钟)',
        attrs: {
            allowClear: true,
            readonly: true,
            min: 1,
            style: {
                width: '100%'
            }
        }
    },
    tubeCount: {
        component: 'AInputNumber',
        label: '试管总数上限(个)',
        attrs: {
            allowClear: true,
            readonly: true,
            min: 1,
            style: {
                width: '100%'
            }
        }
    },
    alarmData: {
        component: 'AInputNumber',
        label: '标本存放最长时间阈值(分钟)',
        attrs: {
            allowClear: true,
            readonly: true,
            min: 1,
            style: {
                width: '100%'
            }
        }
    },
    alarmCount: {
        component: 'AInputNumber',
        label: '标本存放剩余量阈值(个)',
        attrs: {
            allowClear: true,
            readonly: true,
            min: 1,
            style: {
                width: '100%'
            }
        }
    },
    lockData: {
        component: 'AInputNumber',
        label: '柜门未关闭报警时间阈值(分钟)',
        attrs: {
            allowClear: true,
            readonly: true,
            min: 1,
            style: {
                width: '100%'
            }
        }
    }
}

export const ThresholdConfig = {
    disinfectData: {
        component: 'AInputNumber',
        label: '消毒时长设定(分钟)',
        attrs: {
            allowClear: true,
            min: 1,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
    },
    tubeCount: {
        component: 'AInputNumber',
        label: '试管总数上限(个)',
        attrs: {
            allowClear: true,
            min: 1,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
    },
    alarmData: {
        component: 'AInputNumber',
        label: '标本存放最长时间阈值(分钟)',
        attrs: {
            allowClear: true,
            min: 1,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
    },
    alarmCount: {
        component: 'AInputNumber',
        label: '标本存放剩余量阈值(个)',
        attrs: {
            allowClear: true,
            min: 1,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
    },
    lockData: {
        component: 'AInputNumber',
        label: '柜门未关闭报警时间阈值(分钟)',
        attrs: {
            allowClear: true,
            min: 1,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
    }
}

export const VideoConfig = reactive({
    serials: {
        component: 'ACheckboxGroup',
        label: '可控设备',
        attrs: {
            options: deviceOptions,
            style: {
                width: '100%'
            }
        },
        slots: [
            { name: 'default', component: 'AInput' }
        ],
        rules: [{ required: true, message: '请选择可控设备', trigger: 'blur' }]
    },
    file: {
        component: 'Upload',
        label: '文件',
        attrs: {
            showVIDEO: true,
            selectedFn: (file: File) => {
                DeviceStore.videoForm.file = [file]
            },
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '文件不能为空', trigger: 'blur' }]
    }
})


export const VersionConfig = reactive({
    versionUrl: {
        component: 'ASelect',
        label: '版本号',
        attrs: {
            allowClear: true,
            placeholder: '版本号',
            changeOnSelect: true,
            options: versionOptions,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '版本号不能为空', trigger: 'blur' }]
    },
    serials: {
        component: 'CheckBoxGroup',
        label: '设备升级',
        attrs: {
            options: deviceVersionOptions,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: '请选择可控设备', trigger: 'blur' }]
    }
})